﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Media.Animation;
using iMapa.UI.ModelView.Main;

namespace iMapa.Common
{
    /// <summary>
    /// Interaction logic for ViewImage.xaml
    /// </summary>
    public partial class ViewImage : UserControl
    {
        public ViewImage()
        {
            InitializeComponent();
        }

        private void onMouseEnter(object sender, MouseEventArgs e)
        {
            (Resources["onMouseAnim"] as Storyboard).Begin();
              }
        
        private void onMouseLeave(object sender, MouseEventArgs e)
        {
            (Resources["onMouseAnimBack"] as Storyboard).Begin();
        }

        private void EditButton_Click(object sender, RoutedEventArgs e)
        {
            MapViewModel model = ((MapViewModel)this.DataContext);
            model.Root.CurrentViewObject = model;
        }

        public bool ReadOnlyMode
        {
            get {
                Button edit = (Button)this.FindName("EditButton");
                return edit.Visibility == Visibility.Hidden;
                }
            set {
                Button edit = (Button)this.FindName("EditButton");
                edit.Visibility = value ? Visibility.Hidden : Visibility.Visible;
            }
        }

        public ImageSource ImageSource
        {
            get
            {
                Image image = (Image)this.FindName("mapa");
                return image.Source;
            }
            set
            {
                Image image = (Image)this.FindName("mapa");
                image.Source = value;
            }
        }
    }
}
